package com.zyl.shardingsphere.demos.web.controller;


import com.zyl.shardingsphere.demos.web.service.UserService;
import com.zyl.shardingsphere.demos.web.service.impl.UserServiceImpl;
import com.zyl.shardingsphere.demos.web.po.TUser;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zyl
 * @description
 * @since 2024/6/28
 */
@Controller
@RequestMapping("/users")
public class UserController {

    @Resource
    private UserServiceImpl userServiceImpl;

    @Resource
    private UserService userService;

    @PostMapping("/add")
    public void addUser(@RequestBody TUser tUser) {

//        userService.saveMy(tUser);

//        // 执行保存操作
        userServiceImpl.save(tUser);
    }

    @GetMapping("/get")
    public List<TUser> getAllUsers() {
        List<TUser> list = userServiceImpl.list();
        return list;
    }
}
